package org.example;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

public class algorithm_Demo6_1 {
    public static void main(String[] args) {
        Girlfriend gf1=new Girlfriend("xiaoyang",17,1.73);
        Girlfriend gf2=new Girlfriend("xiaoyang",18,1.70);
        Girlfriend gf3=new Girlfriend("xiaowei",18,1.71);
        Girlfriend gf4=new Girlfriend("xiaowe",19,1.71);

        Girlfriend[] arr={gf1,gf2,gf3,gf4};


        Arrays.sort(arr,(Girlfriend o1, Girlfriend o2)-> {
                //年龄  身高 姓名字母 升序
                double temp= o1.getAge()-o2.getAge();

                temp=temp==0?o1.getHeight()-o2.getHeight():temp;

                temp=temp==0?o1.getName().compareTo(o2.getName()):temp;

                if(temp>0){
                    return 1;
                }else if(temp<0){
                    return -1;
                }else{
                    return 0;
                }
        });
        System.out.println(Arrays.toString(arr));
        System.out.println("=============1");
        //斐波那契数列1
        int[]arr1=new int[12];
        arr1[0]=1;
        arr1[1]=1;
        for (int i = 2; i < arr1.length; i++) {
            arr1[i]=arr1[i-1]+arr1[i-2];
        }
        System.out.println(arr1[arr1.length-1]);
        System.out.println("=============2");
        System.out.println(fibonacci(12));
        System.out.println("=============3");
        System.out.println(fn(1));
        System.out.println("=============4");
        System.out.println(Fn(20 ));
        System.out.println("=============5");
        System.out.println(Fn1(20));
    }
    //斐波那契数列2
    public static int fibonacci(int n){
        if(n==1||n==2){
            return 1;
        }
        return fibonacci(n-1)+fibonacci(n-2);
    }
    //递归典例
    //吃桃子
    public static int fn(int n){
        if(n<=0){
            return -1;
        }
        if(n==10){
            return 1;
        }
        return (fn(n+1)+1)*2;
    }
    //爬楼梯  一次可以爬1阶 也可以爬2阶
    public static int Fn(int n){
        if(n==1){
            return 1;
        }
        if(n==2){
            return 2;
        }
        return Fn(n-1)+Fn(n-2);
    }
    //爬楼梯  一次可以爬1阶 也可以爬2阶 也可以爬3阶
    public static int Fn1(int n){
        if(n==1){
            return 1;
        }
        if(n==2){
            return 2;
        }
        if(n==3){
            return 4;
        }
        return Fn1(n-1)+Fn1(n-2)+Fn1(n-3);
    }
}

